package com.dz.tool.Utils;

import java.io.*;
import java.util.List;

public class CMDUtils {

    public static void runCmd(String cmd) throws Exception {
        int finished=0;
        try {
            Runtime rt=Runtime.getRuntime();
            Process proc=rt.exec("cmd /c "+cmd);
            InputStream stderr = proc.getErrorStream();
            InputStreamReader isr = new InputStreamReader(stderr,"GBK");
            BufferedReader br = new BufferedReader(isr);
            String line=null;
            while((line=br.readLine())!=null){
                System.out.println(line);
            }
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //获取根目录
    public static String FileUrl(){
        try {
            File files = new File("");
            return files.getCanonicalPath();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) throws Exception {

        String cmds = "IMPDP C##SCROTTS/root@127.0.0.1:1521/ORCL DUMPFILE=A.DMP remap_schema=TEST1:C##SCROTTS remap_tablespace=NVHLCLM_TBS_DAT:TEST1";

        runCmd(cmds);

    }

}
